package com.itheima.controller;

import com.itheima.common.Result;
import com.itheima.service.SetmealService;
import com.itheima.vo.UserDishVo;
import com.itheima.vo.UserSetmealVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :WuJunJie
 * packageName :com.itheima.controller
 * fileName :SetMealController
 * creationTime :2022-11-27 15:11
 */
@RestController
@RequestMapping("setmeal")
@Slf4j
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @GetMapping("list")
    public Result selectsetmeals(@RequestParam(name="categoryId") String categoryId,
                               @RequestParam(name = "status")Integer status){
        List<UserSetmealVo> userdishVos=setmealService.selectSetmeals(categoryId, status);
        return Result.success(userdishVos);
    }

    @GetMapping("dish/{id}")
    public Result selectSetmealById(@PathVariable(name="id")String id){
        UserSetmealVo userSetmealVo = setmealService.selectDishesById(id);
        return Result.success(userSetmealVo);
    }

}
